package org.example.thread.threadException;

import lombok.SneakyThrows;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * @Auther:Liu
 * @Testname:DemoD
 * @Date:2025/8/14 15:15
 */
public class DemoD {
    private int sum=0;
    private List<Integer> list;

    public DemoD() {
        list = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            int num = new Random().nextInt(100);
            list.add(num);
        }
    }

    @SneakyThrows
    public void jisuan(){
        for (int i = 0; i < list.size(); i++) {
            sum+=list.get(i);
            Thread.sleep(100);
        }
    }

    public int sum(){
        return sum;
    }
}
